<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>PNG: Chunk by Chunk &mdash; PyPNG v0.0.11 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.0.11',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="PyPNG v0.0.11 documentation" href="index.html" />
    <link rel="next" title="How fast is PyPNG?" href="tr20091230.html" />
    <link rel="prev" title="The png Module" href="png.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="tr20091230.html" title="How fast is PyPNG?"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="png.html" title="The png Module"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">PyPNG v0.0.11 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="png-chunk-by-chunk">
<h1>PNG: Chunk by Chunk<a class="headerlink" href="#png-chunk-by-chunk" title="Permalink to this headline">¶</a></h1>
<p>The PNG specification defines 18 chunk types.  This document is intended
to help users who are interested in a particular PNG chunk type.  If you
have a particular PNG chunk type in mind, you can look here to see what
support PyPNG provides for it.</p>
<div class="section" id="critical-chunks">
<h2>Critical Chunks<a class="headerlink" href="#critical-chunks" title="Permalink to this headline">¶</a></h2>
<div class="section" id="ihdr">
<h3><tt class="docutils literal"><span class="pre">IHDR</span></tt><a class="headerlink" href="#ihdr" title="Permalink to this headline">¶</a></h3>
<p>Generated automatically by PyPNG.  The <tt class="docutils literal"><span class="pre">IHDR</span></tt> chunk specifies image
size, colour model, bit depth, and interlacing.  All possible
(valid) combinations can be produced with suitable arguments to the
<a title="png.Writer" class="reference external" href="png.html#png.Writer"><tt class="xref docutils literal"><span class="pre">png.Writer()</span></tt></a> class.</p>
</div>
<div class="section" id="plte">
<h3><tt class="docutils literal"><span class="pre">PLTE</span></tt><a class="headerlink" href="#plte" title="Permalink to this headline">¶</a></h3>
<p>Correctly handled when a PNG image is read.  Can be generated for a
colour type 3 image by using the <tt class="docutils literal"><span class="pre">palette</span></tt> argument to the
<a title="png.Writer" class="reference external" href="png.html#png.Writer"><tt class="xref docutils literal"><span class="pre">png.Writer()</span></tt></a> class.  PNG images with colour types other than 3 can
also have a <tt class="docutils literal"><span class="pre">PLTE</span></tt> chunk (a suggested palette); it is not currently
possible to add a <tt class="docutils literal"><span class="pre">PLTE</span></tt> chunk for these images using PyPNG.</p>
</div>
<div class="section" id="idat">
<h3><tt class="docutils literal"><span class="pre">IDAT</span></tt><a class="headerlink" href="#idat" title="Permalink to this headline">¶</a></h3>
<p>Generated automatically from the pixel data presented to PyPNG.
Multiple <tt class="docutils literal"><span class="pre">IDAT</span></tt> chunks (of bounded size) can be generated by using
<tt class="docutils literal"><span class="pre">chunk_limit</span></tt> argument to the <a title="png.Writer" class="reference external" href="png.html#png.Writer"><tt class="xref docutils literal"><span class="pre">png.Writer()</span></tt></a> class.</p>
</div>
<div class="section" id="iend">
<h3><tt class="docutils literal"><span class="pre">IEND</span></tt><a class="headerlink" href="#iend" title="Permalink to this headline">¶</a></h3>
<p>Generated automatically.</p>
</div>
</div>
<div class="section" id="ancillary-chunks">
<h2>Ancillary Chunks<a class="headerlink" href="#ancillary-chunks" title="Permalink to this headline">¶</a></h2>
<div class="section" id="trns">
<h3><tt class="docutils literal"><span class="pre">tRNS</span></tt><a class="headerlink" href="#trns" title="Permalink to this headline">¶</a></h3>
<p>Generated for most colour types when the <tt class="docutils literal"><span class="pre">transparent</span></tt> argument is
supplied to the <a title="png.Writer" class="reference external" href="png.html#png.Writer"><tt class="xref docutils literal"><span class="pre">png.Writer()</span></tt></a> to specify a transparent colour.  For
colour type 3, colour mapped images, a <tt class="docutils literal"><span class="pre">tRNS</span></tt> chunk will be generated
automatically from the <tt class="docutils literal"><span class="pre">palette</span></tt> argument when a palette with alpha
(opacity) values is supplied.</p>
</div>
<div class="section" id="chrm">
<h3><tt class="docutils literal"><span class="pre">cHRM</span></tt><a class="headerlink" href="#chrm" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="gama">
<h3><tt class="docutils literal"><span class="pre">gAMA</span></tt><a class="headerlink" href="#gama" title="Permalink to this headline">¶</a></h3>
<p>When reading a PNG image the <tt class="docutils literal"><span class="pre">gAMA</span></tt> chunk is converted to a floating
point gamma value; this value is returned in the <tt class="docutils literal"><span class="pre">info</span></tt> dictionary:
<tt class="docutils literal"><span class="pre">info['gamma']</span></tt>.  When writing, the <tt class="docutils literal"><span class="pre">gamma</span></tt> argument to the
<a title="png.Writer" class="reference external" href="png.html#png.Writer"><tt class="xref docutils literal"><span class="pre">png.Writer()</span></tt></a> class will generate a <tt class="docutils literal"><span class="pre">gAMA</span></tt> chunk.</p>
</div>
<div class="section" id="iccp">
<h3><tt class="docutils literal"><span class="pre">iCCP</span></tt><a class="headerlink" href="#iccp" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="sbit">
<h3><tt class="docutils literal"><span class="pre">sBIT</span></tt><a class="headerlink" href="#sbit" title="Permalink to this headline">¶</a></h3>
<p>When reading a PNG image the <tt class="docutils literal"><span class="pre">sBIT</span></tt> chunk will make PyPNG rescale the
pixel values so that they all have the width implied by the <tt class="docutils literal"><span class="pre">sBIT</span></tt>
chunk.  It is possible for a PNG image to have an <tt class="docutils literal"><span class="pre">sBIT</span></tt> chunk that
specifies 3 different values for the significant bits in each of the 3
colour channels.  In this case PyPNG only uses the largest value.  When
writing a PNG image, an <tt class="docutils literal"><span class="pre">sBIT</span></tt> chunk will be generated if need
according to the <tt class="docutils literal"><span class="pre">bitdepth</span></tt> argument specified.  Values other than 1,
2, 4, 8, or 16 will generate an <tt class="docutils literal"><span class="pre">sBIT</span></tt> chunk, as will values less than
8 for images with more than one plane.</p>
</div>
<div class="section" id="srgb">
<h3><tt class="docutils literal"><span class="pre">sRGB</span></tt><a class="headerlink" href="#srgb" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="text">
<h3><tt class="docutils literal"><span class="pre">tEXt</span></tt><a class="headerlink" href="#text" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="ztxt">
<h3><tt class="docutils literal"><span class="pre">zTXt</span></tt><a class="headerlink" href="#ztxt" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="itxt">
<h3><tt class="docutils literal"><span class="pre">iTXt</span></tt><a class="headerlink" href="#itxt" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="bkgd">
<h3><tt class="docutils literal"><span class="pre">bKGD</span></tt><a class="headerlink" href="#bkgd" title="Permalink to this headline">¶</a></h3>
<p>When a PNG image is read, a <tt class="docutils literal"><span class="pre">bKGD</span></tt> chunk will add the <tt class="docutils literal"><span class="pre">background</span></tt>
key to the <tt class="docutils literal"><span class="pre">info</span></tt> dictionary.  When writing a PNG image, a <tt class="docutils literal"><span class="pre">bKGD</span></tt>
chunk will be generated when the <tt class="docutils literal"><span class="pre">background</span></tt> argument is used.</p>
</div>
<div class="section" id="hist">
<h3><tt class="docutils literal"><span class="pre">hIST</span></tt><a class="headerlink" href="#hist" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="phys">
<h3><tt class="docutils literal"><span class="pre">pHYs</span></tt><a class="headerlink" href="#phys" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="splt">
<h3><tt class="docutils literal"><span class="pre">sPLT</span></tt><a class="headerlink" href="#splt" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
<div class="section" id="time">
<h3><tt class="docutils literal"><span class="pre">tIME</span></tt><a class="headerlink" href="#time" title="Permalink to this headline">¶</a></h3>
<p>Ignored when reading.  Not generated.</p>
</div>
</div>
<div class="section" id="non-standard-chunks">
<h2>Non-standard Chunks<a class="headerlink" href="#non-standard-chunks" title="Permalink to this headline">¶</a></h2>
<p>Generally it is not possible to generate PNG images with any other chunk
types.  When reading a PNG image, processing it using the chunk
interface, <tt class="docutils literal"><span class="pre">png.Reader.chunks</span></tt>, will allow any chunk to be processed
(by user code).</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">PNG: Chunk by Chunk</a><ul>
<li><a class="reference external" href="#critical-chunks">Critical Chunks</a><ul>
<li><a class="reference external" href="#ihdr"><tt class="docutils literal"><span class="pre">IHDR</span></tt></a></li>
<li><a class="reference external" href="#plte"><tt class="docutils literal"><span class="pre">PLTE</span></tt></a></li>
<li><a class="reference external" href="#idat"><tt class="docutils literal"><span class="pre">IDAT</span></tt></a></li>
<li><a class="reference external" href="#iend"><tt class="docutils literal"><span class="pre">IEND</span></tt></a></li>
</ul>
</li>
<li><a class="reference external" href="#ancillary-chunks">Ancillary Chunks</a><ul>
<li><a class="reference external" href="#trns"><tt class="docutils literal"><span class="pre">tRNS</span></tt></a></li>
<li><a class="reference external" href="#chrm"><tt class="docutils literal"><span class="pre">cHRM</span></tt></a></li>
<li><a class="reference external" href="#gama"><tt class="docutils literal"><span class="pre">gAMA</span></tt></a></li>
<li><a class="reference external" href="#iccp"><tt class="docutils literal"><span class="pre">iCCP</span></tt></a></li>
<li><a class="reference external" href="#sbit"><tt class="docutils literal"><span class="pre">sBIT</span></tt></a></li>
<li><a class="reference external" href="#srgb"><tt class="docutils literal"><span class="pre">sRGB</span></tt></a></li>
<li><a class="reference external" href="#text"><tt class="docutils literal"><span class="pre">tEXt</span></tt></a></li>
<li><a class="reference external" href="#ztxt"><tt class="docutils literal"><span class="pre">zTXt</span></tt></a></li>
<li><a class="reference external" href="#itxt"><tt class="docutils literal"><span class="pre">iTXt</span></tt></a></li>
<li><a class="reference external" href="#bkgd"><tt class="docutils literal"><span class="pre">bKGD</span></tt></a></li>
<li><a class="reference external" href="#hist"><tt class="docutils literal"><span class="pre">hIST</span></tt></a></li>
<li><a class="reference external" href="#phys"><tt class="docutils literal"><span class="pre">pHYs</span></tt></a></li>
<li><a class="reference external" href="#splt"><tt class="docutils literal"><span class="pre">sPLT</span></tt></a></li>
<li><a class="reference external" href="#time"><tt class="docutils literal"><span class="pre">tIME</span></tt></a></li>
</ul>
</li>
<li><a class="reference external" href="#non-standard-chunks">Non-standard Chunks</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="png.html"
                                  title="previous chapter">The png Module</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="tr20091230.html"
                                  title="next chapter">How fast is PyPNG?</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/chunk.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="tr20091230.html" title="How fast is PyPNG?"
             >next</a> |</li>
        <li class="right" >
          <a href="png.html" title="The png Module"
             >previous</a> |</li>
        <li><a href="index.html">PyPNG v0.0.11 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, David Jones.
      Last updated on 2010-01-05T10:31:12.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
    </div>
  </body>
</html>